/*
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2025-05-29 10:03:04
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-01 22:03:26
 * @FilePath: \guanggu_traffic\src\request\request.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { instance } from "./index";
/******
 * 用户注册接口
 * @param {*}  data = {username,password,type="common"||'admin'|"traffic"}
 * ******/ 
function registerHttp(data){
 return instance({
    url:"/api/register",
    method:"POST",
    data:data
 })
}
/*****
 * 用户登录@param{*} data={username,password,type="common"|"admin"|"traffic"}
 *  
 * *******/
function loginHttp(data) {
    console.log(data);
    return instance({
        url:"/api/login",
        method:"POST",
        data:data
    }) 
}

/****查询用户信息***
 * @param {*} type="common"||"admin"||"traffic"//用户类型* 
 * *********************/ 
function getUserInfoHttp(type){
return instance({
    url:"/api/user",
    method:"GET",
    params:{
        type,
    }
})
}
/***
 * //退出登录
 * @param{*} data = {username,type="common"||"admin"||"traffic"}
 * 
 * 
 * *********/
function logoutHttp({username,type}){
 return instance({
    url:"/api/logout",
    method:"POST",
    data:{
        username,
        type
    }
 })
}

/**
 *  删除用户
 @param{*} data = {username,type="common"||"admin"||"traffic"}} * 
************* */ 
function deleteUserHttp({username,type,}){
    return instance({
        url:"/api/delete",
        method:"POST",
        data:{
            username,
            type
        }
    })
}
/***
 *修改密码
 @param {*} data = {username,type="normal"||"admin"||"traffic"}
 * 
 * ************/ 
function changePasswordHttp({username,password,type,newPassword}){
 return instance({
    url:"/api/change",
    method:"POST",
    data:{
        username,
        password,
        type,
        newPassword
    }
 })
}

/***
 *修改用户信息
 @param {*} data = {username,oldtype,newType,newPassword}
 * 
 * ************/ 
 function modifyUserInfoHttp(data){
    return instance({
       url:"/api/user/modify",
       method:"POST",
       data
    })
   }
/**
 * 查询公告信息
 *
 */
function getNoticeHttp() {
    return instance({
        url: "/api/notice",
        method: "GET",
    });
}
/**
 * 添加公告
 * @param {Object} data = {title, content,time} //公告内容
 */
function addNoticeHttp(data) {
    return instance({
        url: "/api/notice",
        method: "POST",
        data,
    });
}
/**
 * 查询报告信息
 *
 */
function getReportHttp() {
    return instance({
        url: "/api/roadcondition",
        method: "GET",
    });
}
/** 
*添加路况
*@param {Object} data = {name，type，address，signage，time，describe，status,position} //报告内容
*/
function addReportHttp(data) {
    return instance({
        url: "/api/roadcondition/add",
        method: "POST",
        data,
    });
}
/** 
*删除路况
*@param {Object} data = {id} //报告id
*/
function delReportHttp(data) {
    return instance({
        url: "/api/roadcondition/delete",
        method: "DELETE",
        params: data,
    });
}
/** 
*修改路况
*@param {Object} data = {id} //报告id
*/
function updateReportHttp(data) {
    return instance({
        url: "/api/roadcondition/update",
        method: "POST",
        data,
    });
}

//同一暴露
export {
    registerHttp,
    loginHttp,
    getUserInfoHttp,
    logoutHttp,
    deleteUserHttp,
    changePasswordHttp,
    modifyUserInfoHttp,
    getNoticeHttp,
    addNoticeHttp,

    
    getReportHttp,
    addReportHttp,
    delReportHttp,
    updateReportHttp
}
